package com.kingdee.eas.hr.rec.client;

import com.kingdee.bos.BOSException;
import com.kingdee.bos.ctrl.extendcontrols.KDBizPromptBox;
import com.kingdee.bos.ctrl.kdf.table.ICell;
import com.kingdee.bos.ctrl.kdf.table.IRow;
import com.kingdee.bos.ctrl.kdf.table.KDTSelectBlock;
import com.kingdee.bos.ctrl.kdf.table.KDTSelectManager;
import com.kingdee.bos.ctrl.kdf.table.KDTable;
import com.kingdee.bos.ctrl.swing.KDCheckBoxMenuItem;
import com.kingdee.bos.ctrl.swing.KDContainer;
import com.kingdee.bos.ctrl.swing.KDDatePicker;
import com.kingdee.bos.ctrl.swing.KDTextArea;
import com.kingdee.bos.ctrl.swing.KDWorkButton;
import com.kingdee.bos.dao.IObjectCollection;
import com.kingdee.bos.dao.IObjectPK;
import com.kingdee.bos.dao.IObjectValue;
import com.kingdee.bos.dao.ormapping.ObjectUuidPK;
import com.kingdee.bos.dao.query.IQueryExecutor;
import com.kingdee.bos.dao.query.QueryExecutorFactory;
import com.kingdee.bos.metadata.MetaDataPK;
import com.kingdee.bos.metadata.entity.EntityViewInfo;
import com.kingdee.bos.metadata.entity.FilterInfo;
import com.kingdee.bos.metadata.entity.FilterItemCollection;
import com.kingdee.bos.metadata.entity.FilterItemInfo;
import com.kingdee.bos.metadata.entity.SelectorItemCollection;
import com.kingdee.bos.ui.face.CoreUIObject;
import com.kingdee.bos.ui.face.IItemAction;
import com.kingdee.bos.ui.face.IUIFactory;
import com.kingdee.bos.ui.face.IUIObject;
import com.kingdee.bos.ui.face.IUIWindow;
import com.kingdee.bos.ui.face.ItemAction;
import com.kingdee.bos.ui.face.UIFactory;
import com.kingdee.bos.ui.util.IUIActionPostman;
import com.kingdee.bos.util.BOSUuid;
import com.kingdee.eas.base.message.MAGroupInfo;
import com.kingdee.eas.base.message.client.MAGroupF7;
import com.kingdee.eas.basedata.org.AdminOrgUnitInfo;
import com.kingdee.eas.basedata.org.PositionInfo;
import com.kingdee.eas.basedata.org.PositionMemberInfo;
import com.kingdee.eas.basedata.person.PersonInfo;
import com.kingdee.eas.common.client.OprtState;
import com.kingdee.eas.common.client.UIContext;
import com.kingdee.eas.common.client.UIFactoryName;
import com.kingdee.eas.framework.ICoreBase;
import com.kingdee.eas.framework.batchHandler.RequestContext;
import com.kingdee.eas.hr.emp.client.EmployeeMultiF7PromptBox;
import com.kingdee.eas.hr.rec.IInterActivityPublishInfo;
import com.kingdee.eas.hr.rec.IInterviewActivity;
import com.kingdee.eas.hr.rec.IInterviewActivityEntry;
import com.kingdee.eas.hr.rec.IInterviewActivityFacade;
import com.kingdee.eas.hr.rec.IRecCommonUtilFacade;
import com.kingdee.eas.hr.rec.InterActivityPublishInfoFactory;
import com.kingdee.eas.hr.rec.InterActivityPublishInfoInfo;
import com.kingdee.eas.hr.rec.InterviewActivityEntryFactory;
import com.kingdee.eas.hr.rec.InterviewActivityEntryInfo;
import com.kingdee.eas.hr.rec.InterviewActivityFacadeFactory;
import com.kingdee.eas.hr.rec.InterviewActivityFactory;
import com.kingdee.eas.hr.rec.InterviewActivityInfo;
import com.kingdee.eas.hr.rec.OutPositionInfo;
import com.kingdee.eas.hr.rec.PubInfoReceiveMaGroupCollection;
import com.kingdee.eas.hr.rec.PubInfoReceiveMaGroupInfo;
import com.kingdee.eas.hr.rec.PubInfoReceivePersonCollection;
import com.kingdee.eas.hr.rec.PubInfoReceivePersonInfo;
import com.kingdee.eas.hr.rec.RecCommonException;
import com.kingdee.eas.hr.rec.RecCommonUtilFacadeFactory;
import com.kingdee.eas.hr.rec.util.PublishInfoPrintProvider;
import com.kingdee.eas.hr.rec.util.RecUtils;
import com.kingdee.eas.hr.train.client.TrainUtils;
import com.kingdee.eas.util.SysUtil;
import com.kingdee.eas.util.client.EASResource;
import com.kingdee.eas.util.client.ExceptionHandler;
import com.kingdee.eas.util.client.MsgBox;
import com.kingdee.jdbc.rowset.IRowSet;
import java.awt.event.ActionEvent;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.swing.JButton;
import javax.swing.KeyStroke;
import org.apache.log4j.Logger;

public class InterviewActivityPublishUI extends
		AbstractInterviewActivityPublishUI implements ItemListener {
	private static final Logger logger = CoreUIObject
			.getLogger(InterviewActivityPublishUI.class);
	private static final String RES = "com.kingdee.eas.hr.rec.client.InterviewActivityResource";
	private final Set personSet = new HashSet();
	private String interviewActivityId;

	public InterviewActivityPublishUI() throws Exception {
	}

	public void onLoad() throws Exception {
		this.kdtPerson.checkParsed();
		super.onLoad();
		String program = this.textProgram.getText();
		if (program == null && program.trim().length() <= 0) {
			InterActivityPublishInfoInfo info = null;
			try {
				IInterviewActivityFacade facade = InterviewActivityFacadeFactory
						.getRemoteInstance();
				info = (InterActivityPublishInfoInfo) facade
						.getLastestPublishInfo();
			} catch (Exception e) {
				super.handUIException(e);
			}
			if (info != null && "".equals(info.toString())) {
				this.textProgram.setText(info.getProgram());
			}
		}

		init();
		if ((this.editData.getId() == null)
				&& (getOprtState() == OprtState.ADDNEW)) {
			initText();
		}
	}

	public void initWorkButton() {
		super.initWorkButton();
		this.btnSend.setIcon(EASResource.getIcon("imgTbtn_deliverto"));
	}

	protected void beforeStoreFields(ActionEvent e) throws Exception {
		String contactInfo = this.textContactInfo.getText().trim();
		if ((contactInfo == null) || (contactInfo.length() <= 0)) {
			MsgBox.showWarning(EASResource.getString(
					"com.kingdee.eas.hr.rec.client.InterviewActivityResource",
					"contactInfo_can_not_null"));
			this.textContactInfo.requestFocusInWindow();
			SysUtil.abort();
		}
		String require = this.textRequire.getText().trim();
		if ((require == null) || (require.length() <= 0)) {
			MsgBox.showWarning(EASResource.getString(
					"com.kingdee.eas.hr.rec.client.InterviewActivityResource",
					"positionInfo_can_not_null"));
			this.textRequire.requestFocusInWindow();
			SysUtil.abort();
		}
		Date sDate = (Date) this.pkStartDate.getValue();
		Date eDate = (Date) this.pkEndDate.getValue();
		if (sDate == null) {
			MsgBox.showWarning(EASResource.getString(
					"com.kingdee.eas.hr.rec.client.InterviewActivityResource",
					"startDate_can_not_null"));
			this.pkStartDate.requestFocusInWindow();
			SysUtil.abort();
		}
		if (eDate == null) {
			MsgBox.showWarning(EASResource.getString(
					"com.kingdee.eas.hr.rec.client.InterviewActivityResource",
					"endDate_can_not_null"));
			this.pkEndDate.requestFocusInWindow();
			SysUtil.abort();
		}
		if (sDate.after(eDate)) {
			MsgBox.showWarning(EASResource.getString(
					"com.kingdee.eas.hr.rec.client.InterviewActivityResource",
					"endDate_must_bigger_startDate"));
			this.pkEndDate.requestFocusInWindow();
			SysUtil.abort();
		}
	}

	private void init() throws Exception {
		this.interviewActivityId = getUIContext().get("selectedActivityId")
				.toString();

		JButton btnAddPerson = this.contPerson.add(new ActionAddtPerson());
		btnAddPerson.setIcon(EASResource.getIcon("imgTbtn_usermanage"));
		btnAddPerson.setToolTipText(EASResource.getString(
				"com.kingdee.eas.hr.rec.client.InterviewActivityResource",
				"add"));
		JButton btnRemoveLineData = this.contPerson
				.add(new ActionRemovePerson());
		btnRemoveLineData.setIcon(EASResource.getIcon("imgTbtn_logoutuser"));
		btnRemoveLineData.setToolTipText(EASResource.getString(
				"com.kingdee.eas.hr.rec.client.InterviewActivityResource",
				"remove"));

		MAGroupF7 mAGroupF7 = new MAGroupF7(this);
		this.prmtMaGroup.setSelector(mAGroupF7);

		this.prmtMaGroup.setEditable(false);

		this.pkStartDate.setRequired(true);
		this.pkEndDate.setRequired(true);
		this.textContactInfo.setRequired(true);
		this.textRequire.setRequired(true);

		Object[] maGroup = this.editData.getMaGroup().toArray();
		if ((maGroup != null) && (maGroup.length > 0)) {
			try {
				IInterviewActivityFacade facade = InterviewActivityFacadeFactory
						.getRemoteInstance();
				List list = facade.getMaGroupInfo(this.editData.getId()
						.toString());
				this.prmtMaGroup.setValue(list);
			} catch (Exception e) {
				super.handUIException(e);
			}

		}

		String intro = this.textIntroduce.getText();
		String purpose = this.textPurpose.getText();
		if ((OprtState.ADDNEW.equals(getOprtState())) || (intro == null)
				|| (intro.trim().length() <= 0) || (purpose == null)
				|| (purpose.trim().length() <= 0)) {
			InterActivityPublishInfoInfo info = null;
			try {
				IInterviewActivityFacade facade = InterviewActivityFacadeFactory
						.getRemoteInstance();
				info = (InterActivityPublishInfoInfo) facade
						.getLastestPublishInfo();
			} catch (Exception e) {
				super.handUIException(e);
			}
			if (info != null) {
				if ((intro == null) || (intro.trim().length() <= 0)) {
					this.textIntroduce.setText(info.getIntroduce());
				}

			}

			if ((purpose == null) || (purpose.trim().length() <= 0)) {
				SelectorItemCollection sic = RecUtils.getSic(new String[] {
						"id", "purpose" });
				InterviewActivityInfo activityInfo = InterviewActivityFactory
						.getRemoteInstance()
						.getInterviewActivityInfo(
								new ObjectUuidPK(this.interviewActivityId), sic);
				this.textPurpose.setText(activityInfo.getPurpose());
			}
		}
	}

	public void loadFields() {
		super.loadFields();

		setPersonDept();
	}

	private void setPersonDept() {
		Object[] person = this.editData.getPerson().toArray();
		this.personSet.clear();
		if ((person != null) && (person.length > 0)) {
			int i = 0;
			for (int j = person.length; i < j; i++) {
				PubInfoReceivePersonInfo rpi = (PubInfoReceivePersonInfo) person[i];
				this.personSet.add(rpi.getPerson().getId());
			}
		}

		if (getOprtState() == OprtState.EDIT) {
			Map map = null;
			try {
				IRecCommonUtilFacade commonFacade = RecCommonUtilFacadeFactory
						.getRemoteInstance();
				map = commonFacade.getPersonPosition(this.personSet);
			} catch (Exception e) {
				super.handleException(e);
			}
			if (map != null) {
				int size = this.kdtPerson.getRowCount();

				for (int i = 0; i < size; i++) {
					IRow row = this.kdtPerson.getRow(i);
					PersonInfo personInfo = (PersonInfo) row.getCell(
							"person.person").getValue();
					PositionMemberInfo positionInfo = (PositionMemberInfo) map
							.get(personInfo.getId().toString());
					if (positionInfo == null)
						continue;
					row.getCell("person.dept.name").setValue(
							positionInfo.getPosition().getAdminOrgUnit()
									.getName());
					row.getCell("person.position.name").setValue(
							positionInfo.getPosition().getName());
				}
			}
		}
	}

	public void actionSubmit_actionPerformed(ActionEvent e) throws Exception {
		InterviewActivityInfo acitvityInfo = new InterviewActivityInfo();
		acitvityInfo.setId(BOSUuid.read(this.interviewActivityId));
		this.editData.setInterviewActivity(acitvityInfo);

		List list = (List) this.prmtMaGroup.getValue();
		PubInfoReceiveMaGroupCollection ma = this.editData.getMaGroup();
		ma.clear();
		if (list != null) {
			int i = 0;
			for (int size = list.size(); i < size; i++) {
				MAGroupInfo groupInfo = (MAGroupInfo) list.get(i);
				PubInfoReceiveMaGroupInfo info = new PubInfoReceiveMaGroupInfo();
				info.setMaGroup(groupInfo);
				info.setPublishInfo(this.editData);
				ma.add(info);
			}
		}

		this.chkMenuItemSubmitAndAddNew.setSelected(false);
		super.actionSubmit_actionPerformed(e);
	}

	public void actionPrint_actionPerformed(ActionEvent e) throws Exception {
		if (getOprtState().equals(OprtState.ADDNEW)) {
			MsgBox.showWarning(EASResource.getString(
					"com.kingdee.eas.hr.rec.client.InterviewActivityResource",
					"publishInfo_null"));
			SysUtil.abort();
		}
		if (isModify()) {
			actionSubmit_actionPerformed(e);
		}
		PublishInfoPrintProvider.executePrint(this.interviewActivityId, null,
				this);
	}

	public void actionPrintPreview_actionPerformed(ActionEvent e)
			throws Exception {
		if (getOprtState().equals(OprtState.ADDNEW)) {
			MsgBox.showWarning(EASResource.getString(
					"com.kingdee.eas.hr.rec.client.InterviewActivityResource",
					"publishInfo_null"));
			SysUtil.abort();
		}
		if (isModify()) {
			actionSubmit_actionPerformed(e);
		}
		PublishInfoPrintProvider.executePrintView(this.interviewActivityId,
				null, this);
	}

	protected IObjectValue createNewData() {
		return new InterActivityPublishInfoInfo();
	}

	protected ICoreBase getBizInterface() throws Exception {
		return InterActivityPublishInfoFactory.getRemoteInstance();
	}

	public void itemStateChanged(ItemEvent e) {
		if (e.getStateChange() == 1) {
			this.prmtMaGroup.setEnabled(true);
		} else {
			this.prmtMaGroup.setEnabled(false);
		}
	}

	public void actionSend_actionPerformed(ActionEvent e) throws Exception {
		if ((this.prmtMaGroup.getValue() == null)
				&& (this.kdtPerson.getRowCount() <= 0)) {
			MsgBox.showWarning(this, EASResource.getString(
					"com.kingdee.eas.hr.rec.client.InterviewActivityResource",
					"recievePerson_can_not_null"));
			SysUtil.abort();
		}
		if (isModify()) {
			actionSubmit_actionPerformed(e);
		}
		IInterviewActivityFacade facade = InterviewActivityFacadeFactory
				.getRemoteInstance();
		IInterActivityPublishInfo pulishInfoDao = InterActivityPublishInfoFactory
				.getRemoteInstance();
		String publishInfoId = null;
		StringBuffer sql = new StringBuffer();
		if ((this.editData != null) && (this.editData.getId() != null)) {
			publishInfoId = this.editData.getId().toString();
			sql.append("where id = ").append("'").append(publishInfoId).append(
					"'");
			sql.append(" and ").append(" published = 1");
		}

		boolean isSendMail = false;
		UIContext uiContext = new UIContext(this);
		uiContext.put("ID", null);
		if ((this.editData != null) && (this.editData.getId() != null)
				&& (pulishInfoDao.exists(sql.toString()))) {
			uiContext.put("info", EASResource.getString(
					"com.kingdee.eas.hr.rec.client.InterviewActivityResource",
					"pubInfo_has_send"));
		} else {
			uiContext.put("info", EASResource.getString(
					"com.kingdee.eas.hr.rec.client.InterviewActivityResource",
					"select_other_activity"));
		}
		IUIWindow uiWindow = UIFactory
				.createUIFactory(UIFactoryName.MODEL)
				.create(ActivityPubInfoSendMailAskUI.class.getName(), uiContext);
		ActivityPubInfoSendMailAskUI ui = (ActivityPubInfoSendMailAskUI) uiWindow
				.getUIObject();
		uiWindow.show();
		isSendMail = ui.isSendMail();
		boolean isCancel = ui.isCancel();
		if (!isCancel) {
			if (isSendMail) {
				String str = facade.checkPersonEmail(publishInfoId);
				if ("true".equals(str)) {
					try {
						facade.sendPublishInfo(this.interviewActivityId,
								publishInfoId, true);
					} catch (Exception ex1) {
						MsgBox.showError(this, ex1.getMessage());
						SysUtil.abort();
					}
					MsgBox.showInfo(EASResource.getString(
							"com.kingdee.eas.hr.rec.client.RecCommonResource",
							"send_success"));
				} else {
					int isContinue = MsgBox
							.showConfirm2New(
									this,
									str
											+ EASResource
													.getString(
															"com.kingdee.eas.hr.rec.client.RecCommonResource",
															"email_is_null_continue"));

					if (isContinue == 0) {
						try {
							facade.sendPublishInfo(this.interviewActivityId,
									publishInfoId, true);
						} catch (RecCommonException ex2) {
							MsgBox.showError(this, ex2.getMessage());
							SysUtil.abort();
						}
						MsgBox
								.showInfo(EASResource
										.getString(
												"com.kingdee.eas.hr.rec.client.RecCommonResource",
												"send_success"));
					} else {
						facade.sendPublishInfo(this.interviewActivityId,
								publishInfoId, false);
						MsgBox
								.showInfo(EASResource
										.getString(
												"com.kingdee.eas.hr.rec.client.RecCommonResource",
												"message_send_success"));
					}
				}
			} else {
				facade.sendPublishInfo(this.interviewActivityId, publishInfoId,
						false);
				MsgBox.showInfo(EASResource.getString(
						"com.kingdee.eas.hr.rec.client.RecCommonResource",
						"message_send_success"));
			}
		}
	}

	public IObjectPK runSubmit() throws Exception {
		IObjectPK id = super.runSubmit();
		this.editData.setId(BOSUuid.read(id.toString()));
		if (getOprtState() == OprtState.ADDNEW) {
			setOprtState(OprtState.EDIT);
		}
		return id;
	}

	private void initText() {
		if (this.interviewActivityId == null) {
			return;
		}
		InterviewActivityInfo info = null;
		List entryList = null;
		try {
			SelectorItemCollection sic = RecUtils.getSic(new String[] { "id",
					"email", "phone", "person.name" });
			IInterviewActivity dao = InterviewActivityFactory
					.getRemoteInstance();
			info = dao.getInterviewActivityInfo(new ObjectUuidPK(
					this.interviewActivityId), sic);
			IInterviewActivityEntry entryDao = InterviewActivityEntryFactory
					.getRemoteInstance();
			List selectorList = new ArrayList();
			selectorList.add("id");
			selectorList.add("amount");
			selectorList.add("description");
			selectorList.add("position.id");
			selectorList.add("position.name");
			selectorList.add("dept.id");
			selectorList.add("dept.name");
			selectorList.add("outPosition.id");
			selectorList.add("outPosition.name");
			selectorList.add("adminOrgUnit.id");

			entryList = entryDao.getEntryByAcitityId(this.interviewActivityId,
					selectorList);
		} catch (Exception e) {
			ExceptionHandler.handle(e);
		}
		if (info != null) {
			StringBuffer contact = new StringBuffer();
			String phone = info.getPhone();
			String email = info.getEmail();
			String person = info.getPerson().getName();
			contact.append(
					EASResource.getString(
							"com.kingdee.eas.hr.rec.client.RecCommonResource",
							"address")).append(":    \n");
			contact.append(
					EASResource.getString(
							"com.kingdee.eas.hr.rec.client.RecCommonResource",
							"postcode")).append(":    \n");
			contact.append(EASResource.getString(
					"com.kingdee.eas.hr.rec.client.InterviewActivityResource",
					"contact_person"));
			contact.append(":");
			contact.append(person);
			contact.append("   \n");
			contact.append(EASResource.getString(
					"com.kingdee.eas.hr.rec.client.InterviewActivityResource",
					"contact_phone"));
			contact.append(":");
			if ((phone != null) && (phone.length() > 0)) {
				contact.append(phone);
			}
			contact.append("    \n");

			contact.append("email");
			contact.append(":");
			if ((email != null) && (email.length() > 0)) {
				contact.append(info.getEmail()).append("    \n");
			} else {
				contact.append("    \n");
			}

			this.textContactInfo.setText(contact.toString());

			Map map = new HashMap();
			StringBuffer request = new StringBuffer();
			int deptCount = 1;
			if ((entryList != null) && (entryList.size() > 0)) {
				int i = 0;
				for (int j = entryList.size(); i < j; i++) {
					InterviewActivityEntryInfo entryInfo = (InterviewActivityEntryInfo) entryList
							.get(i);
					if (entryInfo.getDept() != null) {
						Object deptId = entryInfo.getDept().getId();
						if (map.containsKey(deptId)) {
//							deptCount = 1;
							Integer num = (Integer) map.get(deptId);
							map.put(deptId, new Integer(num.intValue() + 1));
							request.append(deptCount+".");
							if (entryInfo.getPosition() != null)
								request.append(entryInfo.getPosition()
										.getName());
							else {
								request.append(entryInfo.getOutPosition()
										.getName());
							}
							request
									.append("(")
									.append(entryInfo.getAmount())
									.append(
											EASResource
													.getString(
															"com.kingdee.eas.hr.rec.client.InterviewActivityResource",
															"person")).append(
											")").append("\n");

							if (entryInfo.getDescription() != null) {
								request.append("       ");
								request.append(entryInfo.getDescription())
										.append("\n");
							}

						} else {
							deptCount=1;
							map.put(deptId, new Integer(1));
							if (i != 0) {
								request.append("\n");
							}
							request.append("(").append(
									RecUtils.getCNNumber(deptCount))
									.append(")").append(
											entryInfo.getDept().getName())
									.append("\n");
							request.append("1.");
							if (entryInfo.getPosition() != null)
								request.append(entryInfo.getPosition()
										.getName());
							else {
								request.append(entryInfo.getOutPosition()
										.getName());
							}
							request
									.append("(")
									.append(entryInfo.getAmount())
									.append(
											EASResource
													.getString(
															"com.kingdee.eas.hr.rec.client.InterviewActivityResource",
															"person")).append(
											")").append("\n");

							if (entryInfo.getDescription() != null) {
								request.append("       ");
								request.append(entryInfo.getDescription())
										.append("\n");
							}
							deptCount++;
						}
					}
				}
			}
			this.textRequire.append(request.toString());
		}
	}

	public boolean isPrepareInit() {
		return false;
	}

	public IUIActionPostman prepareInit() {
		IUIActionPostman postman = super.prepareInit();
		RequestContext request = new RequestContext();

		String activityId = getUIContext().get("selectedActivityId").toString();
		request.put("activityId", activityId);

		postman.setRequestContext(request);
		return postman;
	}

	public boolean isPrepareActionSend() {
		return false;
	}

	public RequestContext prepareActionSend(IItemAction itemAction)
			throws Exception {
		RequestContext request = super.prepareActionSend(itemAction);
		if ((this.editData != null) && (this.editData.getId() != null)) {
			String pInfoId = this.editData.getId().toString();
			request.put("publishInfoId", pInfoId);
		}
		request.put("interviewActivityId", this.interviewActivityId);
		return request;
	}

	private StringBuffer getPositionResp(String PositionId) {
		if (PositionId == null) {
			return null;
		}
		StringBuffer request = new StringBuffer();
		IRowSet rowSet = null;
		EntityViewInfo viewInfo = new EntityViewInfo();
		FilterInfo fliter = new FilterInfo();
		fliter.getFilterItems().add(
				new FilterItemInfo("Position.id", PositionId));
		viewInfo.setFilter(fliter);

		IQueryExecutor iqec = QueryExecutorFactory
				.getRemoteInstance(new MetaDataPK("com.kingdee.eas.hr.org.app",
						"PositionRespListQuery"));
		iqec.setObjectView(viewInfo);
		try {
			rowSet = iqec.executeQuery();
		} catch (BOSException e) {
			handUIException(e);
		}
		try {
			int k = 0;
			while (rowSet.next()) {
				if (k == 0) {
					request
							.append(
									EASResource
											.getString(
													"com.kingdee.eas.hr.rec.client.InterviewActivityResource",
													"PositionResp")).append(
									"??\n");
				}
				if (rowSet.getString("name") != null) {
					request.append(rowSet.getString("name")).append("??");
				}
				if (rowSet.getString("description") != null) {
					request.append(rowSet.getString("description"))
							.append("\n");
				}
				k++;
			}
		} catch (SQLException e) {
			handUIException(e);
		}
		return request;
	}

	private StringBuffer getPositionPosi(String PositionId) {
		if (PositionId == null) {
			return null;
		}
		StringBuffer request = new StringBuffer();
		IRowSet rowSet = null;
		EntityViewInfo viewInfo = new EntityViewInfo();
		FilterInfo fliter = new FilterInfo();
		fliter.getFilterItems().add(
				new FilterItemInfo("Position.id", PositionId));
		viewInfo.setFilter(fliter);

		IQueryExecutor iqec = QueryExecutorFactory
				.getRemoteInstance(new MetaDataPK("com.kingdee.eas.hr.org.app",
						"PositionOfPosiQual"));
		iqec.setObjectView(viewInfo);
		try {
			rowSet = iqec.executeQuery();
		} catch (BOSException e) {
			handUIException(e);
		}
		try {
			int k = 0;
			while (rowSet.next()) {
				if (k == 0) {
					request
							.append(
									EASResource
											.getString(
													"com.kingdee.eas.hr.rec.client.InterviewActivityResource",
													"PositionPosi")).append(
									":\n");
				}
				if (rowSet.getString("name") != null) {
					request.append(rowSet.getString("name")).append(":");
				}
				if (rowSet.getString("description") != null) {
					request.append(rowSet.getString("description"))
							.append("\n");
				}
				k++;
			}
		} catch (SQLException e) {
			handUIException(e);
		}
		return request;
	}

	private class ActionRemovePerson extends ItemAction {
		public ActionRemovePerson() {
			this(null);
		}

		public ActionRemovePerson(IUIObject uiObject) {
			super();
			String _tempStr = "";
			putValue("AcceleratorKey", KeyStroke.getKeyStroke("ctrl shift D"));
			putValue("ShortDescription", _tempStr);
			putValue("LongDescription", _tempStr);
			putValue("Name", _tempStr);
		}

		public void actionPerformed(ActionEvent e) {
			if ((InterviewActivityPublishUI.this.kdtPerson.getSelectManager()
					.size() == 0)
					|| (RecUtils
							.isTableColumnSelected(InterviewActivityPublishUI.this.kdtPerson))) {
				return;
			}
			int top = InterviewActivityPublishUI.this.kdtPerson
					.getSelectManager().get().getTop();
			IRow row = InterviewActivityPublishUI.this.kdtPerson.getRow(top);
			IObjectValue detailData = (IObjectValue) row.getUserObject();
			PersonInfo personInfo = (PersonInfo) row.getCell("person.person")
					.getValue();
			if (personInfo != null) {
				InterviewActivityPublishUI.this.personSet.remove(personInfo
						.getId());
			}
			InterviewActivityPublishUI.this.kdtPerson.removeRow(top);
			IObjectCollection collection = (IObjectCollection) InterviewActivityPublishUI.this.kdtPerson
					.getUserObject();
			if ((collection != null) && (detailData != null)) {
				collection.removeObject(detailData);
			}
		}
	}

	private class ActionAddtPerson extends ItemAction {
		public ActionAddtPerson() {
			this(null);
		}

		public ActionAddtPerson(IUIObject uiObject) {
			super();
			String _tempStr = "";
			putValue("AcceleratorKey", KeyStroke.getKeyStroke("ctrl shift I"));
			putValue("ShortDescription", _tempStr);
			putValue("LongDescription", _tempStr);
			putValue("Name", _tempStr);
		}

		public void actionPerformed(ActionEvent e) {
			EmployeeMultiF7PromptBox dlg = new EmployeeMultiF7PromptBox();
			dlg.setIsSingleSelect(false);
			dlg.setModal(true);
			dlg.show();

			if (dlg.isCanceled()) {
				return;
			}
			Object[] obj = (Object[]) dlg.getData();
			Map map = new HashMap();
			Set personIds = new HashSet();
			for (int i = 0; i < obj.length; i++) {
				PersonInfo personInfo = (PersonInfo) obj[i];
				personIds.add(personInfo.getId().toString());
			}
			try {
				IRecCommonUtilFacade commonFacade = RecCommonUtilFacadeFactory
						.getRemoteInstance();
				map = commonFacade.getPersonPosition(personIds);
			} catch (Exception exc) {
				ExceptionHandler.handle(exc);
			}

			for (int i = 0; i < obj.length; i++) {
				PersonInfo personInfo = (PersonInfo) obj[i];
				if (InterviewActivityPublishUI.this.personSet
						.contains(personInfo.getId()))
					continue;
				String id = personInfo.getId().toString();
				IRow row = TrainUtils
						.addLine(InterviewActivityPublishUI.this.kdtPerson);
				row.getCell("person.person").setValue(personInfo);
				row.getCell("person.number").setValue(personInfo.getNumber());
				row.getCell("person.name").setValue(personInfo.getName());
				row.getCell("person.email").setValue(personInfo.getEmail());
				PositionMemberInfo positionInfo = (PositionMemberInfo) map
						.get(id);
				if (positionInfo != null) {
					row.getCell("person.dept.name").setValue(
							positionInfo.getPosition().getAdminOrgUnit()
									.getName());
					row.getCell("person.position.name").setValue(
							positionInfo.getPosition().getName());
				}
				InterviewActivityPublishUI.this.personSet.add(id);
			}
		}
	}
}